import { Component, Output, EventEmitter, Input,  } from '@angular/core';

/** 借钱进度模态框
 */
@Component({
  selector: 'borrow-progress',
  templateUrl: 'borrow-progress.html'
})
export class BorrowProgressComponent {

  // picker属性display绑定显示
  private pickerShow: string= null;
  // className绑定是否添加
  private addClass: boolean= false;
  // 一次性定时器,处理display和过渡动画冲突
  private timer: any = null;

  @Input() options: any= {}; // 接受参数
  @Output() cancelEvent = new EventEmitter<any>();
  constructor()
  {}

  /*** 显示picker
   * */
  show() {
    this.pickerShow = 'block';
    this.clearTime();
    this.timer= setTimeout(()=>{
      this.addClass = true;
    },30);
  }

  /*** 隐藏picker
   * */
  hide() {
    this.addClass = false;
    this.clearTime();
    this.timer = setTimeout(()=>{
      this.pickerShow = null;
    },500);

    this.emitPickerCancel();
  }

  /*** 离开
   * */
  emitPickerCancel(): void
  {
    this.cancelEvent.emit();
  }

  /** 清除定时器
   * */
  clearTime(){
    if(this.timer){
      clearTimeout(this.timer);
      this.timer= null;
    }
  }

}
